<template>


    <a-modal :title="title" :width="1280" :destroyOnClose="true" :maskClosable="false"
             :visible="visible" @cancel="handleCancel"  :footer="false"
    >

        <a-table bordered
                 :columns="columns"
                 :rowKey="record => record.id"
                 :dataSource="dataSource"
                 :pagination="pagination"
                 :loading="loading"
                 @change="handleTableChange"
        >



            <template slot="doneTime" slot-scope="text, record">

                {{showDoneTime(record)}}
            </template>

        </a-table>

    </a-modal>

</template>
<script>

    import {
      getNoticeList


    } from '../public/http.js';
    import {noticeTable, pagination} from "../public/colums";


    export default {

        props:["logObj"],


        data() {
            return {
                title:"任务日志",
                visible: true, //modal 显示状态
                //数据表格
                dataSource: [],
                pagination: {
                    ...pagination
                }, //复制预设的分页参数
                loading: false, //表格loading
                columns: noticeTable, //表头管理
                searchForm: {
                    taskId:this.logObj.id,
                    code: '',
                    name: '',
                    remark: '',
                    status: ''
                },


            };
        },
        methods: {


            showDoneTime(record){
                if(record.noticeStatus.length>0){
                    return this.$exMod.formatDate(record.updateTime, 'Y-m-d:H:i:s')
                }else{
                    return '#NA'
                }



            },
            //关闭弹窗
            handleCancel() {
                this.visible = false;
                this.$emit('closeModal', {
                    render: false
                });
            },




            //完成监听
            onSubmit(e) {
                //AJAX时间数据处理

                //关闭弹窗
                this.visible = false;
                this.$emit('closeModal', {render: false});

            },



            //==========表格数据加载===========


            getTableData(){


                this.loading = true;
                let searchData = this.$exMod.filterObjEmpty(this.searchForm); //删除对象中的空值

                getNoticeList(this.pagination, searchData).then(res => {
                    this.loading = false;
                    if (res.code === 0) {
                        this.dataSource = res.data.result; //表格数据
                        this.pagination.total = res.data.total; //总记录条数
                    }
                });


            },



            //1.2翻页监听
            handleTableChange(pagination) {
                this.pagination.current = pagination.current;
                this.pagination.pageSize = pagination.pageSize;
                this.getTableData();
            },



        },

        created() {
            this.pagination.current =1;
            this.getTableData();
        }
    };
</script>